package com.sjzd.meeting.service.impl;

import com.sjzd.meeting.dao.WxUserDAO;
import com.sjzd.meeting.pojo.WxUser;
import com.sjzd.meeting.service.IWxUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class WxUserServiceImpl implements IWxUserService {

    @Autowired
    private WxUserDAO wxUserDAO;

    @Transactional
    @Override
    public int save(WxUser user) {
        // 检查是否已有该对象
        WxUser temp = wxUserDAO.selectByOpenId(user.getOpenid());
        if (null != temp) {
            return 0;
        }
        return wxUserDAO.insert(user);
    }

    @Override
    public WxUser selectByOpenId(String openid) {
        return wxUserDAO.selectByOpenId(openid);
    }
}
